#******************************************************************
#
# Copyright 2016 Samsung Electronics All Rights Reserved.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

##
# Notification build script
##

Import('env')

lib_env = env.Clone()
SConscript('#service/third_party_libs.scons', 'lib_env')
notification_sample_env = lib_env.Clone()

target_os = env.get('TARGET_OS')
######################################################################
# Build flags
######################################################################
notification_sample_env.AppendUnique(CPPPATH=[
    '../../../include',
    '../../provider/inc',
    '../../consumer/inc',
    '../../common',
    '#/resource/c_common',
    '#/resource/c_common/oic_malloc/include',
    '#/resource/c_common/oic_string/include',
    '#/resource/csdk/include',
    '#/resource/csdk/stack/include',
    '#/resource/csdk/connectivity/api',
    '#/resource/include',
    '#/resource/oc_logger/include'
    '../../../src/common'
])

notification_sample_env.PrependUnique(LIBS=[
    'resource_directory',
    'oc',
    'liboctbstack',
    'oc_logger',
    'connectivity_abstraction',
])

notification_sample_env.AppendUnique(CXXFLAGS=['-std=c++0x', '-frtti'])
if target_os not in ['windows', 'winrt']:
    notification_sample_env.AppendUnique(
        CXXFLAGS=['-O2', '-g', '-Wall', '-fmessage-length=0'])

if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
    notification_sample_env.AppendUnique(LINKFLAGS=['-Wl,--no-undefined'])

if target_os == 'linux':
    notification_sample_env.AppendUnique(LIBS=['pthread'])

if target_os == 'android':
    notification_sample_env.AppendUnique(CXXFLAGS=['-frtti', '-fexceptions'])
    notification_sample_env.AppendUnique(LIBS=['gnustl_shared', 'log'])

if env.get('SECURED') == '1':
    notification_sample_env.AppendUnique(
        LIBS=['mbedtls', 'mbedx509', 'mbedcrypto'])
if target_os in ['linux', 'tizen']:
    notification_sample_env.AppendUnique(LIBS=['rt'])

####################################################################
# Source files and Targets
######################################################################
notification_sample_provider_env = notification_sample_env.Clone()

notification_sample_provider_env.AppendUnique(
    LIBS='libnotification_provider_wrapper')
notification_sample_provider_env.AppendUnique(LIBS='libnotification_provider')
notificationproviderwrapper = notification_sample_provider_env.Program(
    'notificationproviderwrapper', 'notificationserviceprovider.cpp')
i_notificationprovider = notification_sample_provider_env.Install(
    env.get('BUILD_DIR'), notificationproviderwrapper)

notification_sample_consumer_env = notification_sample_env.Clone()
notification_sample_consumer_env.AppendUnique(
    LIBS='libnotification_consumer_wrapper')
notification_sample_consumer_env.AppendUnique(LIBS='libnotification_consumer')
notificationconsumerwrapper = notification_sample_consumer_env.Program(
    'notificationconsumerwrapper', 'notificationserviceconsumer.cpp')
i_notificationconsumer = notification_sample_consumer_env.Install(
    env.get('BUILD_DIR'), notificationconsumerwrapper)
